/**
 * @author v.lugovsky
 * created on 16.12.2015
 */
(function () {
    'use strict';

    angular.module('BlurAdmin.pages.class')
        .controller('ClassListCtrl', ClassListCtrl);

    /** @ngInject */
    function ClassListCtrl($scope,ClassModel,$state,AppUtils) {

        //班级管理
        $scope.gotoManage = function(id){
            if(!AppUtils.isUndefinedOrNull(id)){
                $state.go("class.manage",{id:id});
            }else{
                AppUtils.showAlert("请选择要查看的班级！");
            }
        }

        var vm = this;
        vm.teacherName = "";
        vm.className = "";
        vm.page = {};
        vm.initPage = function(){
            ClassModel.getClassList({
                teacherName: vm.teacherName,
                className: vm.className,
                pageInfo: {
                    pageSize: 10,
                    pageNumber: vm.page.pageIndex
                }
            }).$promise.then(function(response){
                vm.page = _.clone(response.pageResult);
            });
        }
        vm.initPage();

        vm.cleanParams = function (){
            vm.className = "";
            vm.teacherName = "";
        }
    }

})();
